import { _decorator, assert, Component, Node } from 'cc';
import { AudioMgr, SoundName } from '../Mgr/AudioMgr';
import { UIMgr } from '../Mgr/UIMgr';
import { AssetList } from '../Global';
import { LocalStorageMgr } from '../Mgr/LocalStorageMgr';
import { SingleShopCat } from './SingleShopCat';
import { GameScene } from '../GameScene/GameScene';
const { ccclass, property } = _decorator;

@ccclass('GameShop')
export class GameShop extends Component {

    //猫咪层
    @property(Node)
    private CatLoad: Node = null;

    public Cb: Function = null;

    /**
     * 更新商店
     */
    public UpdateShop() {
        for (let i = 0; i < LocalStorageMgr.Instance.LOCAL_STORAGE_DATA.CATINFO.length; i++) {
            this.CatLoad.children[i].getComponent(SingleShopCat).UpdateCat(
                i,
                LocalStorageMgr.Instance.LOCAL_STORAGE_DATA.CATINFO[i].coin,
                LocalStorageMgr.Instance.LOCAL_STORAGE_DATA.CATINFO[i].ishave,
            )
        }
    }

    /**
     * 关闭商店
     */
    public CloseClick() {
        AudioMgr.instance.PlayEffect(SoundName.Click);
        this.Cb && this.Cb();
        UIMgr.Instance.HidePop(AssetList.Pop.GAMESHOP)
    }

}


